package com.andy.mvp;


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;

import com.andy.app_core.net.databus.RxBus;
import com.andy.mvp.test.adapter.GirlAdapter;
import com.andy.mvp.test.bean.Girl;
import com.andy.mvp.test.dagger.DaggerGirlComponent;
import com.andy.mvp.test.dagger.GirlPresentModules;
import com.andy.mvp.test.precenter.GirlPresenter;
import com.andy.mvp.test.view.IGirlView;

import java.util.List;

import javax.inject.Inject;

public class MainActivity extends AppCompatActivity implements IGirlView {
    ListView listView;
    @Inject
    GirlPresenter presenter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listView=findViewById(R.id.listview);

//        new GirlPrecenter(this).fetch();
//        presenter =new GirlPresenter(this);

        DaggerGirlComponent.builder()
                .girlPresentModules(new GirlPresentModules(this))
                .build().inject(this);
        RxBus.getInstance().register(presenter);
    }

    @Override
    public void showGirls(List<Girl> girls) {
        listView.setAdapter(new GirlAdapter(this,girls));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        RxBus.getInstance().unRegister(presenter);
    }
}
